/*
 * @lc app=leetcode.cn id=70 lang=javascript
 *
 * [70] 爬楼梯
 */

// @lc code=start
/**
 * @param {number} n
 * @return {number}
 */
var climbStairs = function (n) {
  //   let dp = [1, 1];

  //   for (let index = 2; index <= n; index++) {
  //     dp[index] = dp[index - 1] + dp[index - 2];
  //   }

  //   return dp[n];

  let prev = 1;

  let cur = 1;

  let next;

  for (let i = 2; i <= n; i++) {
    next = prev + cur;
    prev = cur;
    cur = next;
  }

  return next;
};
// @lc code=end
